//
//  APVideoCommentItemView.m
//  AqualPolo
//
//  Created by dong on 2024/5/13.
//

#import "APVideoCommentItemView.h"

@implementation APVideoCommentItemView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = LYRGBAColor(0, 0, 0, 0.5);
        self.layer.cornerRadius = 20;
        /**
         kCALayerMinXMinYCorner = 1U << 0,
         kCALayerMaxXMinYCorner = 1U << 1,
         kCALayerMinXMaxYCorner = 1U << 2,
         kCALayerMaxXMaxYCorner = 1U << 3,
         */
        self.layer.maskedCorners = kCALayerMinXMinYCorner|kCALayerMinXMaxYCorner|kCALayerMaxXMaxYCorner;

        
        _avatarImageView = [[UIImageView alloc] init];
        _avatarImageView.layer.cornerRadius = 16;
        _avatarImageView.layer.masksToBounds = true;
        [self addSubview:_avatarImageView];
        [_avatarImageView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self).offset(4);
            make.top.equalTo(self).offset(4);
            make.size.mas_equalTo(CGSizeMake(32, 32));
        }];
        
        _contentLabel = [[UILabel alloc] init];
        _contentLabel.textColor = [UIColor whiteColor];
        _contentLabel.font = [LYFont fontWithSize:15 fontName:LYFontNamepfr];
        _contentLabel.textAlignment = NSTextAlignmentLeft;
        _contentLabel.numberOfLines = 0;
        [self addSubview:_contentLabel];
        [_contentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(_avatarImageView.mas_right).offset(8);
            make.top.equalTo(self).offset(10);
            make.bottom.right.equalTo(self).offset(-10);
        }];
    }
    return self;
}

- (void)setCommentModel:(APCommentModel *)commentModel{
    _commentModel = commentModel;
    [_avatarImageView sd_setImageWithURL:[NSURL URLWithString:commentModel.avatar]];
    _contentLabel.text = commentModel.content;
}
@end
